using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for BusinessClass
/// </summary>
public class BusinessClass
{
    #region Class members
    private string username;
    private int userid;
    private string password;
    private string fullname;
    private int roleid;
    private string roleName;

    public int UserId
    {
        get { return userid; }
        set { userid = value; }
    }
    public string UserName
    {
        get { return username; }
        set { username = value; }
    }
    public string Password
    {
        get { return password; }
        set { password = value; }
    }
    public int RoleId
    {
        get { return roleid; }
        set { roleid = value; }
    }
    public string RoleName
    {
        get { return roleName; }
        set { roleName = value; }
    }  
    public string FullName
    {
        get { return fullname; }
        set { fullname = value; }
    }
    #endregion

    public BusinessClass()
    {
        //
        // TODO: Add constructor logic here
        //
    }


    public bool IsValidUser()
    {
        bool isValidUser = false;
        DataTable dt = new DataTable();
        dt = DataAccessClass.GetUserDetails(UserName, Password, RoleId);
        if (dt.Rows.Count == 1)
        {
            UserName = Convert.ToString(dt.Rows[0]["UserName"]);
            UserId = Convert.ToInt32(dt.Rows[0]["UserId"]);
            FullName = Convert.ToString(dt.Rows[0]["FullName"]);
            RoleName = Convert.ToString(dt.Rows[0]["RoleName"]);
            RoleId = Convert.ToInt32(dt.Rows[0]["RoleId"]);
            if (!string.IsNullOrEmpty(FullName) && UserId > 0)
            {
                isValidUser = true;
            }
        }
        return isValidUser;
    }

    public static DataSet GetUserType()
    {
        DataTable dt = new DataTable();
        DataSet ds = new DataSet();
        dt = DataAccessClass.GetLookupData("UserType");
        ds.Tables.Add(dt);
        return ds;
    }

    public static DataSet GetCompanyType()
    {
        DataTable dt = new DataTable();
        DataSet ds = new DataSet();
        dt = DataAccessClass.GetLookupData("CompanyType");
        ds.Tables.Add(dt);
        return ds;
    }


    public static DataTable GetCompanyDetails(int roleId, int compId)
    {
        DataTable dt = new DataTable();
        dt = DataAccessClass.GetCompanyDetails(roleId, compId);
        return dt;
    }

    public enum CompanyType
    {
        Supplier = 3,
        Contractor = 2,
        Transport = 1
    }

    public static DataTable GetVehicleDetails(int roleId, int vehicleId)
    {
        DataTable dt = new DataTable();
        dt = DataAccessClass.GetVehicleDetails(roleId, vehicleId);
        return dt;
    }


    public static DataTable GetEmployeeDetails(int roleId, int empId)
    {
        DataTable dt = new DataTable();
        dt = DataAccessClass.GetEmployeeDetails(roleId, empId);
        return dt;
    }

    internal static DataTable GetChallanDetails(int challanId)
    {
        DataTable dt = new DataTable();
        dt = DataAccessClass.GetChallanDetails(challanId);
        return dt;
    }

    internal static DataTable GetChallanDetails(string challanDate, string transportComp, string challanNo, int challanId, int status)
    {

        DataTable dt = new DataTable();
        dt = DataAccessClass.GetChallanDetails(challanDate, transportComp, challanNo, challanId, status);
        return dt;
    }



    public static DataTable GetMaterialDetais(int roleId, int mId)
    {
        DataTable dt = new DataTable();
        dt = DataAccessClass.GetMaterialDetails(roleId, mId);
        return dt;
    }

    internal static DataTable GetBillDetails(string FromDate, string ToDate, string TransportCompId, string ContractorCompId, string Material)
    {
        DataTable dt = new DataTable();
        dt = DataAccessClass.GetBillDetails(FromDate, ToDate, TransportCompId, ContractorCompId, Material);
        return dt;
    }

    public static int DeleteMaster(string type, int itemId, int userid)
    {
        return DataAccessClass.DeleteDetails(type, itemId, userid);
    }
}
